package com.jiutong.meipenggang.views.rollviewpager;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jiutong.meipenggang.R;
import com.jiutong.meipenggang.entity.MeiLiCaiBean;

import java.util.List;


/**
 * Created by suxi on 2017/6/16.
 */

public class AdvsPagerAdapter extends LoopPagerAdapter {
    private int[] imgs = {
            R.mipmap.banner1,
            R.mipmap.banner1,
            R.mipmap.banner1,
            R.mipmap.banner1
    };

    private List<MeiLiCaiBean.HomeAdsBean> homeAds;
    private Context mContext;

    public AdvsPagerAdapter(Context mContext, RollPagerView viewPager, List<MeiLiCaiBean.HomeAdsBean> homeAds) {
        super(viewPager);
        this.mContext = mContext;
        this.homeAds = homeAds;
    }

    @Override
    public View getView(ViewGroup container, int position) {
        ImageView view = new ImageView(container.getContext());
//        Glide.with(mContext).load(homeAds.get(position).getName()).centerCrop().into(view);
        view.setScaleType(ImageView.ScaleType.CENTER_CROP);
        view.setImageResource(imgs[position]);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public int getRealCount() {
        return homeAds.size();
    }
}
